package com.xqzgj.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xqzgj.system.mapper.StockSupplierMapper;
import com.xqzgj.system.domain.StockSupplier;
import com.xqzgj.system.service.IStockSupplierService;

/**
 * 供应商信息Service业务层处理
 */
@Service
public class StockSupplierServiceImpl implements IStockSupplierService {
    @Autowired
    private StockSupplierMapper stockSupplierMapper;

    /**
     * 查询供应商信息列表
     */
    @Override
    public List<StockSupplier> selectStockSupplierList(StockSupplier stockSupplier) {
        return stockSupplierMapper.selectStockSupplierList(stockSupplier);
    }

    /**
     * 查询供应商信息
     */
    @Override
    public StockSupplier selectStockSupplierById(Long id) {
        return stockSupplierMapper.selectStockSupplierById(id);
    }

    /**
     * 新增供应商信息
     */
    @Override
    public int insertStockSupplier(StockSupplier stockSupplier) {
        return stockSupplierMapper.insertStockSupplier(stockSupplier);
    }

    /**
     * 修改供应商信息
     */
    @Override
    public int updateStockSupplier(StockSupplier stockSupplier) {
        return stockSupplierMapper.updateStockSupplier(stockSupplier);
    }

    /**
     * 批量删除供应商信息
     */
    @Override
    public int deleteStockSupplierByIds(Long[] ids) {
        return stockSupplierMapper.deleteStockSupplierByIds(ids);
    }

    /**
     * 删除供应商信息
     */
    @Override
    public int deleteStockSupplierById(Long id) {
        return stockSupplierMapper.deleteStockSupplierById(id);
    }

    /**
     * 校验供应商编码是否唯一
     */
    @Override
    public boolean checkSupplierCodeUnique(StockSupplier stockSupplier) {
        Long id = stockSupplier.getId() == null ? -1L : stockSupplier.getId();
        StockSupplier info = stockSupplierMapper.checkSupplierCodeUnique(stockSupplier.getSupplierCode());
        return info == null || info.getId().equals(id);
    }

    /**
     * 校验供应商名称是否唯一
     */
    @Override
    public boolean checkSupplierNameUnique(StockSupplier stockSupplier) {
        Long id = stockSupplier.getId() == null ? -1L : stockSupplier.getId();
        StockSupplier info = stockSupplierMapper.checkSupplierNameUnique(stockSupplier.getSupplierName());
        return info == null || info.getId().equals(id);
    }

    /**
     * 更新供应商状态
     */
    @Override
    public int updateStockSupplierStatus(StockSupplier stockSupplier) {
        return stockSupplierMapper.updateStockSupplierStatus(stockSupplier);
    }
}